CREATE DATABASE TerraTourBD
GO

USE TerraTourBD
GO

/*
DROP TABLE TB_PAGOS
GO 

DROP TABLE TB_CLIENTE
GO 

DROP TABLE TB_RESERVA
GO 
*/

CREATE TABLE TB_CLIENTE(
ID_CLIENTE INT PRIMARY KEY IDENTITY,
NOMBRE_COMPLETO VARCHAR(100) NOT NULL,
DNI CHAR(8) NOT NULL,
PWD CHAR(4) NOT NULL
)
GO

CREATE TABLE TB_RESERVA(
ID_RESERVA INT PRIMARY KEY IDENTITY,
ID_CLIENTE INT FOREIGN KEY REFERENCES TB_CLIENTE(ID_CLIENTE),
COSTO_TOTAL FLOAT NOT NULL,
ESTADO_PAGO CHAR NOT NULL DEFAULT 'I'
)
GO

CREATE TABLE TB_PAGOS(
ID_PAGO INT PRIMARY KEY IDENTITY,
NUMERO_COMPROBANTE_PAGO VARCHAR(50) NOT NULL,
ID_RESERVA INT FOREIGN KEY REFERENCES TB_RESERVA(ID_RESERVA),
FECHA_PAGO DATETIME NOT NULL,
NUMERO_OPERACION_BANCO VARCHAR(30) NOT NULL
)
GO

INSERT INTO TB_CLIENTE( NOMBRE_COMPLETO, DNI, PWD)
VALUES('Gian Carlo Vegas R.', '09157696', '1234')
GO

/*SELECT *
FROM TB_CLIENTE*/


INSERT INTO TB_RESERVA(ID_CLIENTE, COSTO_TOTAL)
VALUES(1, 50.00 )
INSERT INTO TB_RESERVA(ID_CLIENTE, COSTO_TOTAL)
VALUES(1, 80.00 )
INSERT INTO TB_RESERVA(ID_CLIENTE, COSTO_TOTAL)
VALUES(1, 40.00 )
GO

SELECT *
FROM TB_RESERVA

update TB_RESERVA
set ESTADO_PAGO = 'I'